<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 实现页面中表格的隔行变色
     -->
    <table></table>
    <script>
      for (j = 1; j < 5; j++) {
        var tab = document.querySelector("table");
        var h = document.createElement("tr");
        h.innerHTML = `${j}${j}${j}`;
        tab.appendChild(h);
        if (j % 2 == 0) {
          h.style.background = "red";
        }
      }
      document.body.appendChild(tab);
    </script>
  </body>
</html>
